<?php js_validate();?>
<form id="form-validated" class="input" action="<?php echo $own_links;?>save" method="post" enctype="multipart/form-data">
		<input type="hidden" name="form_id" id="form_id" value="<?php echo isset($val->form_id)?$val->form_id:'';?>" />
		<table class="table-form" style="width:95%;" border="0">
			<tr>
				<td>Nama Principal</td>
				<td><input type="text" id="form_principal_name" name="form_principal_name" <?php echo $this->dis;?> class="validate[required]"size="50" value="<?php echo isset($val->form_principal_name)?$val->form_principal_name:'';?>" /></td>
			</tr>
            <tr valign="top">
				<td>Alamat Principal</td>
				<td><textarea cols="50" rows="2" id="form_principal_address" name="form_principal_address" <?php echo $this->dis;?> class="validate[required]" /><?php echo isset($val->form_principal_address)?$val->form_principal_address:'';?></textarea></td>
			</tr>
            <tr>
				<td>Nama Obligee</td>
				<td><input type="text" id="form_obligee_name" name="form_obligee_name" <?php echo $this->dis;?> class="validate[required]"size="50" value="<?php echo isset($val->form_obligee_name)?$val->form_obligee_name:'';?>" /></td>
			</tr>
            <tr valign="top">
				<td>Alamat Obligee</td>
				<td><textarea cols="50" rows="2" id="form_obligee_address" <?php echo $this->dis;?> name="form_obligee_address" class="validate[required]" /><?php echo isset($val->form_obligee_address)?$val->form_obligee_address:'';?></textarea></td>
			</tr>
            <!--<tr>
				<td>Nama Marketing</td>
				<td>
                	<select name="form_marketing" class="validate[required]" <?php echo $this->dis;?> id="form_marketing">
                    	<option value="">Pilih Tipe Marketing</option>
                        <?php
							if(count($marketing) > 0){
								foreach($marketing as $r){
									$t = isset($val->form_marketing)?$val->form_marketing:"";
									$s = ($r->marketing_id==$t)?"selected='selected'":'';
									echo "<option value='".$r->marketing_id."' $s >".$r->marketing_name."</option>";
								}
							}
						?>
                    </select>
                </td>
			</tr>-->
			<input type="hidden" value="0" name="form_marketing" <?php echo $this->dis;?> id="form_marketing" />
			
            <tr>
				<td>Tipe Bank Garansi</td>
				<td>
                	<select name="form_bank_garansi_type" class="validate[required]" <?php echo $this->dis;?> id="form_bank_garansi_type">
                    	<option value="">Pilih Tipe Bank Garansi</option>
                        <option value="penawaran" <?php echo (isset($val->form_bank_garansi_type)&& $val->form_bank_garansi_type=="penawaran")?'selected="selected"':'';?>>Penawaran</option>
                        <option value="pelaksanaan" <?php echo (isset($val->form_bank_garansi_type)&& $val->form_bank_garansi_type=="pelaksanaan")?'selected="selected"':'';?> >Pelaksanaan</option>
                        <option value="uang muka" <?php echo (isset($val->form_bank_garansi_type)&& $val->form_bank_garansi_type=="uang muka")?'selected="selected"':'';?> >Uang Muka</option>
                        <option value="pemeliharaan" <?php echo (isset($val->form_bank_garansi_type)&& $val->form_bank_garansi_type=="pemeliharaan")?'selected="selected"':'';?> >Pemeliharaan</option>
                    </select>
                </td>
			</tr>
            <tr>
            	<td>Mata Uang</td>
                <td>
                	<select name="form_mata_uang" class="validate[required]" <?php echo $this->dis;?> id="form_mata_uang">
                        <?php
							if(count($curr) > 0){
								foreach($curr as $r){
									$t = isset($val->form_mata_uang)?$val->form_mata_uang:"";
									$s = ($r->cur_id==$t)?"selected='selected'":'';
									echo "<option value='".$r->cur_id."' $s >".$r->cur_name."</option>";
								}
							}
						?>
                    </select>
                </td>
            </tr>
            <tr>
				<td>Nilai Project</td>
				<td>
                    <input type="text" id="form_contract_value" <?php echo $this->dis;?> name="form_contract_value" class="validate[required,custom[onlyNumber]]"size="30" value="<?php echo isset($val->form_contract_value)?$val->form_contract_value:'';?>" /></td>
			</tr>
            <tr>
				<td>Nilai Jaminan</td>
				<td>                	
                    <input type="text" id="form_guarantee_value" <?php echo $this->dis;?> name="form_guarantee_value" class="validate[required,custom[onlyNumber]]"size="30" value="<?php echo isset($val->form_guarantee_value)?$val->form_guarantee_value:'';?>" /></td>
			</tr>
            <tr>
				<td>Nomor Dokumen</td>
				<td><input type="text" id="form_document_number" <?php echo $this->dis;?> name="form_document_number" class="validate[required]"size="50" value="<?php echo isset($val->form_document_number)?$val->form_document_number:'';?>" /></td>
			</tr>
            <tr valign="top">
				<td>Deskripsi Dokumen</td>
				<td><textarea cols="50" rows="2" id="form_document_desc" <?php echo $this->dis;?> name="form_document_desc" class="validate[required]" /><?php echo isset($val->form_document_desc)?$val->form_document_desc:'';?></textarea></td>
			</tr>
            <tr valign="top">
				<td>Pekerjaan</td>
				<td>
                <textarea cols="50" id="form_job" name="form_job" class="validate[required]" rows="3"><?php echo isset($val->form_job)?$val->form_job:'';?></textarea>
			</tr>
            <tr>
				<td>Jangka Waktu</td>
				<td><input type="text" id="form_as_long_day" <?php echo $this->dis;?> name="form_as_long_day" class="validate[required]"size="5" value="<?php echo isset($val->form_as_long_day)?$val->form_as_long_day:'';?>" /> Hari</td>
			</tr>
            <tr>
				<td>Mulai Tanggal </td>
				<td><input type="text" id="form_start_date" <?php echo $this->dis;?> name="form_start_date" class="validate[required] picker" readonly="readonly" size="15" value="<?php echo isset($val->form_start_date)?$val->form_start_date:'';?>" /> s/d <input type="text" id="form_end_date" name="form_end_date" <?php echo $this->dis;?> class="validate[required] picker" readonly="readonly" size="15" value="<?php echo isset($val->form_end_date)?$val->form_end_date:'';?>" /></td>
			</tr>
            <tr valign="top">
				<td>Dokumen</td>
				<td>
                		 <?php if($this->is_detail==FALSE){ ?>
						 	<input type="file" name="formulir_files" size="30"  id="formulir_files_id"/>
                         			
						 <a href="#" id="link_tambah"><img src="<?php echo themeUrl();?>images/add.png" /></a> <i class="to">*) Klik disini jika ingin upload lebih dari 1 file</i><br />
						 
						 <i style="font-size:10px; color:green;">Tipe File yang bisa diupload : doc|docx|xls|xlsx|pdf|zip|rar|gif|jpg|png</i>
						 <?php } ?>	
						 <div id="formulir_files"></div><br />
                         <?php if(isset($files) && count($files) > 0){
							 	$nomor = 1;
								foreach($files as $r){
								?>
									<div class="file"><?php echo $nomor;?>. 
                                    	<a href="#" class="file_item">Dokumen Pendukung </a>
                                        <?php if($this->is_detail==FALSE){ ?>
                                        <a href="<?php echo $own_links."remove/".$r->file_secret_key."?url=".current_url();?>" class="hapus_item confirm" rel="Apakah anda yakin akan menghapus file ini ?">[ hapus ]</a>
                                        <?php } ?>
                                        <a href="<?php echo base_url()."uploaded/formulir/".$r->file_location.$r->file_name;?>" class="download_item">[ download ]</a>
                                    </div>
								<?php
									$nomor++;
								}
						 }?>
                </td>
			</tr>
            
			<tr><td colspan="2">&nbsp;</td></tr>
			<tr>
				<td><input type="reset" onclick="document.location='<?php echo $own_links;?>'" class="btnbatal" value="Batal" /></td>
				<td align="right">
                <?php if($this->is_detail==FALSE){ ?>
                	<input type="submit" class="btnsimpan" value="Simpan" />
                <?php } ?>
                </td>
			</tr>
		</table>
	</form>

<script language="javascript">
$('#link_tambah').click(function(a){
	rd=Math.floor(Math.random()*1000000);
	html = create_obj(rd);
	$('#formulir_files').append(html);
});

function create_obj(id){
	n_id = "id_"+id;
	obj = "<input type='file' name='formulir_files"+n_id+"' size='30' />";
	return "<div id='div_"+n_id+"' style='margin:4px 0px;'>"+obj+"<a href='#' id='li_"+n_id+"' onClick=_hapus_item('"+n_id+"')><img src='"+THEME_URL+"images/deleteo.png' /></a></div>";	
}
function _hapus_item(i){
	$('#div_'+i).fadeOut("medium",function(){
		$(this).remove(); 
	});
}

</script>
